import java.sql.*;
import com.genexus.ui.*;
import com.genexus.db.*;
import com.genexus.*;

public final class gxrgza extends GXProcedure
{
   public gxrgza( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( gxrgza.class ), "" );
   }

   public gxrgza( int remoteHandle ,
                  ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /*
         This is the first program in the reorganization process.
         It must be compiled and run before any other reorganization
         program.
      */
      /* Lock tables */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("rgzlcktb", new Object[] {"1"}) );
      /* Load data into tables. */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("runpgm", new Object[] {"GXLRI25"}) );
      new gxlri25(remoteHandle, context).execute( ) ;
      GXReorganization.addMsg( localUtil.getMessages().getMessage("runpgm", new Object[] {"GXLRI28"}) );
      new gxlri28(remoteHandle, context).execute( ) ;
      /* Drop integrity constraints (if any). */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("rgzdic", new Object[] {"2"}) );
      /* Create new and temporary tables. */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("rgzctnt", new Object[] {"3"}) );
      GXReorganization.addMsg( localUtil.getMessages().getMessage("filecrea", new Object[] {"GXA0052",""}) );
      cmdBuffer = " DROP TABLE [GXA0052] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE TABLE [GXA0052] ([ModCod] char(10) NOT null , [ModNom] char(50) null , [ModEst] ";
      cmdBuffer += "  char(1) null , [ModFCR] datetime null , [ModHCR] char(8) null , [ModUCR] char(10) ";
      cmdBuffer += "  null , [ModFUM] datetime null , [ModHUM] char(8) null , [ModUUM] char(10) null , ";
      cmdBuffer += "  [MarCodAux] char(10) null )  ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      /* Creating temporary indexes. */
      GXReorganization.addMsg( localUtil.getMessages().getMessage("creaindx", new Object[] {"GXI52 (temp)"}) );
      cmdBuffer = " DROP INDEX [GXA0052].[GXI52] ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cmdBuffer = " CREATE UNIQUE NONCLUSTERED INDEX [GXI52] ON [GXA0052] ([ModCod] ) ";
      ExecuteDirectSQL.execute(context, remoteHandle, "DEFAULT", cmdBuffer) ;
      cleanup();
   }

   protected void cleanup( )
   {
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      cmdBuffer = "" ;
      /* GeneXus formulas. */
   }

   protected String cmdBuffer ;
}

